<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SSE</title>
</head>
<body>
<div id="sse"></div>
<script>
    let eventSource = new EventSource("/stream");
    eventSource.onmessage = function(event){
        document.getElementById("sse").innerHTML= event.data;
    }
    eventSource.addEventListener("foo", (event)=>{
        document.getElementById("sse").innerHTML= event.data;
    });
    eventSource.addEventListener("end", (event)=>{
        eventSource.close();
    });
</script>
</body>
</html>